package com.example.attempt.service.impl;

import com.example.attempt.entity.Course;
import com.example.attempt.entity.Student;
import com.example.attempt.mapper.CourseMapper;
import com.example.attempt.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    CourseMapper courseMapper;
    @Override
    public List<Course> queryAll() {
        return courseMapper.queryAll();
    }

    @Override
    public Course queryById(String cid) {
        return courseMapper.queryById(cid);
    }

    @Override
    public List<Course> queryByTeacher(String tid) {
        return courseMapper.queryByTeacher(tid);
    }
    @Override
    public List<Course> queryByRoom(String croom) {
        return courseMapper.queryByRoom(croom);
    }

    @Override
    public int getNum() {
        return courseMapper.getNum();
    }

//    @Override
//    public int addCourses(List<Course> courses) {
//        Course c = new Course();
//        for(int i=0;i<courses.size();i++){
//            c=courses.get(i);
//            courseMapper.addCourse(c);
//        }
//        return 1;
//    }

    @Override
    public void deleteCourse(String cid) {
        courseMapper.deleteCourse(cid);
    }

    @Override
    public int addCourse(Course c) {
        courseMapper.addCourse(c);
        return 0;
    }

    @Override
    public int changeTid(String cid, String tid) {
        courseMapper.changeTeacher(cid, tid);
        return 1;
    }



    public List<Student> getStudentsNotInCourse(String cid){
        return courseMapper.getNotInCourse(cid);
    }

}